| Conditions | 10 |
| Paths | 397 |
| Total Lines | 54 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
Complex classes like PromisesUserPopulator.foldersAdditionalParameters often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
| 1 | |||
| 153 | PromisesUserPopulator.prototype.foldersAdditionalParameters = function(oData) |
||
| 154 | { |
||
| 155 | if (oData && oData && 'Collection/FolderCollection' === oData['@Object'] && |
||
| 156 | oData['@Collection'] && Utils.isArray(oData['@Collection'])) |
||
| 157 | { |
||
| 158 | if (!Utils.isUnd(oData.Namespace)) |
||
| 159 | { |
||
| 160 | FolderStore.namespace = oData.Namespace; |
||
| 161 | } |
||
| 162 | |||
| 163 | AppStore.threadsAllowed(!!Settings.appSettingsGet('useImapThread') && oData.IsThreadsSupported && true); |
||
| 164 | |||
| 165 | FolderStore.folderList.optimized(!!oData.Optimized); |
||
| 166 | |||
| 167 | var bUpdate = false; |
||
| 168 | |||
| 169 | if (oData.SystemFolders && '' === '' + |
||
| 170 | Settings.settingsGet('SentFolder') + |
||
| 171 | Settings.settingsGet('DraftFolder') + |
||
| 172 | Settings.settingsGet('SpamFolder') + |
||
| 173 | Settings.settingsGet('TrashFolder') + |
||
| 174 | Settings.settingsGet('ArchiveFolder') + |
||
| 175 | Settings.settingsGet('NullFolder')) |
||
| 176 | { |
||
| 177 | Settings.settingsSet('SentFolder', oData.SystemFolders[Enums.ServerFolderType.SENT] || null); |
||
| 178 | Settings.settingsSet('DraftFolder', oData.SystemFolders[Enums.ServerFolderType.DRAFTS] || null); |
||
| 179 | Settings.settingsSet('SpamFolder', oData.SystemFolders[Enums.ServerFolderType.JUNK] || null); |
||
| 180 | Settings.settingsSet('TrashFolder', oData.SystemFolders[Enums.ServerFolderType.TRASH] || null); |
||
| 181 | Settings.settingsSet('ArchiveFolder', oData.SystemFolders[Enums.ServerFolderType.ALL] || null); |
||
| 182 | |||
| 183 | bUpdate = true; |
||
| 184 | } |
||
| 185 | |||
| 186 | FolderStore.sentFolder(this.normalizeFolder(Settings.settingsGet('SentFolder'))); |
||
| 187 | FolderStore.draftFolder(this.normalizeFolder(Settings.settingsGet('DraftFolder'))); |
||
| 188 | FolderStore.spamFolder(this.normalizeFolder(Settings.settingsGet('SpamFolder'))); |
||
| 189 | FolderStore.trashFolder(this.normalizeFolder(Settings.settingsGet('TrashFolder'))); |
||
| 190 | FolderStore.archiveFolder(this.normalizeFolder(Settings.settingsGet('ArchiveFolder'))); |
||
| 191 | |||
| 192 | if (bUpdate) |
||
| 193 | { |
||
| 194 | require('Remote/User/Ajax').saveSystemFolders(Utils.noop, { |
||
| 195 | SentFolder: FolderStore.sentFolder(), |
||
| 196 | DraftFolder: FolderStore.draftFolder(), |
||
| 197 | SpamFolder: FolderStore.spamFolder(), |
||
| 198 | TrashFolder: FolderStore.trashFolder(), |
||
| 199 | ArchiveFolder: FolderStore.archiveFolder(), |
||
| 200 | NullFolder: 'NullFolder' |
||
| 201 | }); |
||
| 202 | } |
||
| 203 | |||
| 204 | Local.set(Enums.ClientSideKeyName.FoldersLashHash, oData.FoldersHash); |
||
| 205 | } |
||
| 206 | }; |
||
| 207 | |||
| 209 |